<!--
 * @Description: 
 * @Author: ljl
 * @Date: 2024-11-11 19:09:26
 * @LastEditors: rendc
 * @LastEditTime: 2024-11-11 19:24:07
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点亮灯泡</title>
</head>
<body>
    <img id="h1" src="./img/image1.png" alt=""><br>
    <div>杰普软件</div> <br>
    <div>Java程序员</div><br>
    <input type="checkbox" name="hobby">电影
    <input type="checkbox" name="hobby">旅游
    <input type="checkbox" name="hobby">游戏
</body>
<script>
    // 获取img标签对象
    var img = document.getElementById('h1');
    // 然后修改src属性
    img.src = "./img/image2.png";
    // 将所有div标签的内容后面加上: very good (红色字体)
    var divs = document.getElementsByTagName('div');
    for (let i = 0; i < divs.length; i++) {
        const div = divs[i];
        div.innerHTML += "<font color='red'>very good</font>";
    }
    var ins = document.getElementsByName('hobby');
    for (let i = 0; i < ins.length; i++) {
        const check = ins[i];
        check.checked = true;
    }
</script>
</html>